package com.dr.springboot.starter.controller;

import com.dr.springboot.starter.VO.ResultVO;
import com.dr.springboot.starter.VO.UserVO;
import com.dr.springboot.starter.enums.ResultEnum;
import com.dr.springboot.starter.util.ResultVOUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * Created by rui on 2018/7/25.
 */
//todo annotation spring RestController=Controller+ResponseBody
@RestController
@RequestMapping("/user")
public class UserController {

//    todo annotation spring GetMapping是RequestMapping的简化
    @GetMapping(value = "/user")
    public ResultVO getUser() {
        UserVO userVO = new UserVO();
        userVO.setUserName("ming");
        userVO.setPassword("aaaaaa1");
        userVO.setAddress("china");
        userVO.setBirthday(new Date());

        return ResultVOUtil.success(userVO);
    }

    @GetMapping(value = "/error")
    public ResultVO getError() {
        return ResultVOUtil.error(ResultEnum.ERROR);
    }
}
